/*
Brian Powell
Title: Factors Affecting Attitudes Toward Transgender Bathroom Use

HYPOTHESES
	
Stated-Hyp 1. The gender identity of a trans person will influence feelings towards the use of a bathroom matching gender identity.
	
	Test-Hyp1: Same as stated
	
Stated-Hyp 2. The gender conformity of the trans individual (i.e. whether they "pass" or not) will influence feelings towards the use of a bathroom matching gender identity.

	Test-Hyp2: Same as stated
	
Stated-Hyp 3. The age of a trans individual will influence feelings towards the use of a bathroom matching gender identity.

	Test-Hyp3: Same as stated
	
********************************************************************************
NOTES
- data for this study was collected twice. On exsite, we have two datasets 
pertaining to this study. This file uses dataset A. 
Dataset B changed the outcome variable (so there is no question about 
bathroom use).
	
- we are excluding the "other" option from the outcome because this was 
an open text entry question and people had all sorts of answers, some of which 
were closer to alignment and others closer to misalignment.	
*/

clear all
use "PowellS4.dta", clear

********************************************************************************

* CONSTRUCT INDICATORS OF EXPERIMENTAL MANIPULATIONS

	* gender identity
	tab PGENID
	destring PGENID, replace
	gen id_male=1 if PGENID==1 // we know this from quex
	replace id_male=0 if PGENID==2
	tab id_male, mis
	
	* gender conformity
	tab PGENCONF
	destring PGENCONF, replace
	lab def conf 1 "conforming" 2 "nonconforming" 3 "ambiguous" 4 "unspecified"
	gen _conforms=1 if PGENCONF==1
	replace _conforms=2 if PGENCONF==2
	replace _conforms=3 if PGENCONF==3
	replace _conforms=4 if PGENCONF==4
	lab val _conforms conf
	tab _conforms, mis
	
		* creating a binary indicator of conformity
		gen conforms=1 if _conforms==1
		replace conforms=0 if _conforms!=1
		tab conforms
	
	* age
	tab PAGESTAT
	destring PAGESTAT, replace
	gen teenager=1 if PAGESTAT==2
	replace teenager=0 if PAGESTAT==1
	tab teenager, mis

* CONSTRUCT OUTCOME MEASURES

	* will R recommend a bathroom aligned with Casey's gender identity
	
	/* Note: Q1A, Q1A_1, Q1B, Q1_B1 all ask the same question and are mutually
	exclusive.
	However, Q1_A has a different response order.
	Creating a new variable that uses a uniform response order.
	*/
	recode Q1A_1 (1=2) (2=1) (3=3) (*=.) // recoding so it aligns will other 3 questions
	
	clonevar bathroom=Q1A
	replace bathroom=Q1A_1 if bathroom==.
	replace bathroom=Q1B if bathroom==.
	replace bathroom=Q1B_1 if bathroom==.
	replace bathroom=. if bathroom ==98
	tab bathroom, mis

	gen genderalign=.
	replace genderalign=1 if id_male==1 & bathroom==1 // aligned
	replace genderalign=1 if id_male==0 & bathroom==2 // aligned
	replace genderalign=0 if id_male==1 & bathroom==2
	replace genderalign=0 if id_male==0 & bathroom==1
	replace genderalign=. if bathroom==3 // if other, consider missing
	
	lab def align 1 "aligned w/ Casey's gender" 0 "misaligned w/ Casey's gender" 
	lab val genderalign align
	tab genderalign, mis
	
********************************************************************************

* TEST HYPOTHESIS 
	
*Test-Hyp 1. The gender identity of a trans person will influence feelings towards the use of a bathroom matching gender identity.
	
	reg genderalign i.id_male
		// reject. 0.788
	tess 1.id_male, init(PowellS4)
	
*Test-Hyp 2. The gender conformity of the trans individual (i.e. whether they "pass" or not) will influence feelings towards the use of a bathroom matching gender identity.

	reg genderalign i.conforms
		// do not reject. 0.000
	tess 1.conforms
	
*Test-Hyp 3. The age of a trans individual will influence feelings towards the use of a bathroom matching gender identity.

	reg genderalign i.teenager
		// do not reject. 0.026
	tess 1.teenager
